﻿using Angle.Krill.Utils;
using Microsoft.VisualBasic.Devices;
using System;
using System.Drawing;

namespace Angle.Krill
{
    internal static class ImageHelper
    {
        public static Bitmap FolderIcon
        {
            get
            {
                return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict["fa-folder"]);
            }
        }
        public static Bitmap OpenFolderIcon
        {
            get
            {
                return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict["fa-folder-open"]);
            }
        }
        public static Bitmap RemoveIcon
        {
            get
            {
                return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict["fa-remove"]);
            }
        }
        public static Bitmap FileIcon
        {
            get
            {
                return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict["fa-file"]);
            }
        }
        public static Bitmap CertificateIcon
        {
            get
            {
                return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict["fa-certificate"]);
            }
        }

        public static Icon ConvertToIcon(Bitmap bitmap)
        {
            System.IntPtr iconHandle = bitmap.GetHicon();
            System.Drawing.Icon icon = Icon.FromHandle(iconHandle);

            return icon;
        }
        internal static Icon GetIcon(string icon, Color? color = null)
        {
            if (string.IsNullOrEmpty(icon))
            {
                return null;
            }

            FontAwesomeHelper.Instance.ForeColor = color ?? Color.Black;
            return FontAwesomeHelper.Instance.GetIcon(FontAwesomeHelper.Instance.TypeDict[icon]);
        }

        internal static Bitmap GetBitmap(string icon, Color? color = null)
        {
            if (string.IsNullOrEmpty(icon))
            {
                return null;
            }

            FontAwesomeHelper.Instance.ForeColor = color ?? Color.Black;
            return FontAwesomeHelper.Instance.GetImage(FontAwesomeHelper.Instance.TypeDict[icon]);
        }

        internal static Image FromFile(string path)
        {
            return Image.FromFile(path);
        }
    }
}
